package com.lwj.liwanjia.adapter.indent;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.MyIndentBean;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * 购物车中的订单
 */

public class ShopUnpaidAdater1 extends SuperBaseAdapter<MyIndentBean.DataBean.GoodsBean.CommodityBean> {

    private boolean flag;
    private Context mContext;

    public ShopUnpaidAdater1(Context context, List<MyIndentBean.DataBean.GoodsBean.CommodityBean> data, boolean flag) {
        super(context, data);
        this.flag = flag;
        this.mContext = context;
    }

    @Override
    public int getItemCount() {
        if (!flag) {
            return super.getItemCount() > 4 ? 4 : super.getItemCount();
        } else {
            return super.getItemCount();
        }
    }

    @Override
    protected void convert(BaseViewHolder holder, MyIndentBean.DataBean.GoodsBean.CommodityBean item, int position) {
        Glide.with(mContext).load(item.getCommodityimage()).into((ImageView) holder.getView(R.id.iv_shangpin));
        holder.setText(R.id.tv_shangpin, item.getCommodityname())
                .setText(R.id.tv_jianjie, item.getCommodityinfo())
                .setText(R.id.tv_price, "￥" + item.getCommodityprice())
                .setText(R.id.tv_num, "*" + item.getCommodityNum());
    }

    @Override
    protected int getItemViewLayoutId(int position, MyIndentBean.DataBean.GoodsBean.CommodityBean item) {
        return R.layout.my_indent_item;
    }
}
